{% extends "base.html" %}

{% block title %}公告板管理{% endblock title %}
{% block subtitle %}公告板管理{% endblock subtitle %}

{% block content %}
    {% set sfl = request.query_params.get("sfl", "") %}
    {% set stx = request.query_params.get("stx", "") %}

    <div class="local_ov01 local_ov">
        <a href="/admin/board_list" class="ov_listall">完整列表</a>    
        <span class="btn_ov01"><span class="ov_txt">生成的公告板的数量</span><span class="ov_num"> {{ total_count|number_format }}狗</span></span>
    </div>

    <form name="fsearch" id="fsearch" class="local_sch01 local_sch" method="get">
        <label for="sfl" class="blind">搜索目标</label>
        <select name="sfl" id="sfl">
        <option value="bo_subject" {{ get_selected('bo_subject', sfl) }}>标题</option>
        <option value="bo_table" {{ get_selected('bo_table', sfl) }}>TABLE</option>
        <option value="gr_id" {{ get_selected('gr_id', sfl) }}>组ID</option>
        </select>
        <label for="stx" class="blind">搜索词<strong class="blind"> 必不可少的</strong></label>
        <input type="text" name="stx" value="{{ stx }}" id="stx" required class="required frm_input">
        <button type="submit" class="btn_submit">
          <span class="blind">搜索</span>
        </button>
    </form>

    <form name="fboardlist" id="fboardlist" action="/admin/board_list_update" onsubmit="return fboardlist_submit(this);" method="post">
        <input type="hidden" name="token" value="">
        <div class="tbl_head01 tbl_wrap">
            <table>
                <caption>公告栏管理列表</caption>
                <thead>
                    <tr>
                        <th scope="col">
                            <label for="chkall" class="blind">完整的公告板</label>
                            <input type="checkbox" name="chkall" value="1" id="chkall" onclick="check_all(this.form)">
                        </th>
                        <th scope="col">{{ subject_sort_link(request, 'gr_id')|safe }}组</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_table')|safe }}TABLE</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_skin')|safe }}皮肤</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_mobile_skin')|safe }}移动电话<br>皮肤</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_subject')|safe }}标题</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_read_point')|safe }}阅读P<span class="blind">点</span></a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_write_point')|safe }}写作P<span class="blind">点</span></a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_comment_point')|safe }}评论P<span class="blind">点</span></a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_download_point')|safe }}向下P<span class="blind">点</span></a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_use_sns')|safe }}SNS<br>使用</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_use_search')|safe }}搜索<br>使用</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_order')|safe }}输出<br>订单</a></th>
                        <th scope="col">{{ subject_sort_link(request, 'bo_device')|safe }}访问设备</a></th>
                        <th scope="col">管理</th>
                    </tr>
                </thead>
                <tbody>
                    {% for board in boards %}
                    <tr class="bg{{ loop.cycle('0', '1') }}">
                        <td class="td_chk">
                            <label for="chk_{{ loop.index0 }}" class="blind">{{ board.bo_subject }}</label>
                            <input type="checkbox" name="chk[]" value="{{ loop.index0 }}" id="chk_{{ loop.index0 }}">
                        </td>
                        <td>
                            {{ get_group_select('gr_id[]', board.gr_id, 'required')|safe }}
                        </td>
                        <td>
                            <input type="hidden" name="bo_table[]" value="{{ board.bo_table }}">
                            <a href="/board/{{ board.bo_table }}">{{ board.bo_table }}</a>
                        </td>
                        <td>
                            <label for="bo_skin[{{ loop.index0 }}]" class="blind">皮肤</label>
                            {{ get_skin_select('board', 'bo_skin[]', board.bo_skin, attribute='required')|safe }}
                        </td>
                        <td>
                            <label for="bo_mobile_skin[]" class="blind">移动皮肤</label>
                            {{ get_skin_select('board', 'bo_mobile_skin[]', board.bo_mobile_skin, device='mobile')|safe }}
                        </td>
                        <td>
                            <label for="bo_subject_{{ loop.index0 }}" class="blind">公告板标题<strong class="blind"> 必不可少的</strong></label>
                            <input type="text" name="bo_subject[]" value="{{ board.bo_subject }}" id="bo_subject_{{ loop.index0 }}" required class="required tbl_input bo_subject full_input" size="10">
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_read_point_{{ loop.index0 }}" class="blind">读取点</label>
                            <input type="text" name="bo_read_point[]" value="{{ board.bo_read_point }}" id="bo_read_point_{{ loop.index0 }}" class="tbl_input" size="2">
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_write_point_{{ loop.index0 }}" class="blind">书写点</label>
                            <input type="text" name="bo_write_point[]" value="{{ board.bo_write_point }}" id="bo_write_point_{{ loop.index0 }}" class="tbl_input" size="2">
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_comment_point_{{ loop.index0 }}" class="blind">评论点</label>
                            <input type="text" name="bo_comment_point[]" value="{{ board.bo_comment_point }}" id="bo_comment_point_{{ loop.index0 }}" class="tbl_input" size="2">
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_download_point_{{ loop.index0 }}" class="blind">向下<br>点</label>
                            <input type="text" name="bo_download_point[]" value="{{ board.bo_download_point }}" id="bo_download_point_{{ loop.index0 }}" class="tbl_input" size="2">
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_use_sns_{{ loop.index0 }}" class="blind">SNS<br>使用</label>
                            <input type="checkbox" name="bo_use_sns[]" value="{{ loop.index0 }}" id="bo_use_sns_{{ loop.index0 }}" {{ 'checked' if board.bo_use_sns }}>
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_use_search_{{ loop.index0 }}" class="blind">搜索<br>使用</label>
                            <input type="checkbox" name="bo_use_search[]" value="{{ loop.index0 }}" id="bo_use_search_{{ loop.index0 }}" {{ 'checked' if board.bo_use_search }}>
                        </td>
                        <td class="td_numsmall">
                            <label for="bo_order_{{ loop.index0 }}" class="blind">输出<br>订单</label>
                            <input type="text" name="bo_order[]" value="{{ board.bo_order }}" id="bo_order_{{ loop.index0 }}" class="tbl_input" size="2">
                        </td>
                        <td class="td_mngsmall">
                            <label for="bo_device_{{ loop.index0 }}" class="blind">访问设备</label>
                            <select id="bo_device_{{ loop.index0 }}" name="bo_device[]">
                                <option value="both" {{ get_selected(board.bo_device, 'both') }}>全部</option>
                                <option value="pc" {{ get_selected(board.bo_device, 'pc') }}>PC</option>
                                <option value="mobile" {{ get_selected(board.bo_device, 'mobile') }}>移动电话</option>
                                <option value="mobile" {{ get_selected(board.bo_device, 'mobile') }}>移动电话</option>
                            </select>
                        </td>
                        <td class="td_mng td_mng_m">
                            <a href="/admin/board_form/{{ board.bo_table }}?{{ request.query_params }}" class="btn btn_03">校正</a>                            
                            <a href="/admin/board_copy/{{ board.bo_table }}" class="board_copy btn btn_02" target="win_board_copy">复制</a>
                        </td>
                    </tr>
                    {% else %}
                    <tr><td colspan="15">没有材料.</td></tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        <div class="btn_fixed_top">
            <input type="submit" name="act_button" value="选择校正" onclick="document.pressed=this.value" class="btn_02 btn">
            <input type="submit" name="act_button" value="删除所选内容" onclick="document.pressed=this.value" class="btn_02 btn">
            <a href="/admin/board_form" id="bo_add" class="btn_01 btn">添加公告板</a>
        </div>
    </form>

    {{ paging|safe }}

    <script>
    function fboardlist_submit(f) {
        if (!is_checked("chk[]")) {
            alert(document.pressed + " 选择您想要的一个或多个项目.");
            return false;
        }

        if (document.pressed == "删除所选内容") {
            if (!confirm("是否确实要删除所选材质?")) {
                return false;
            }

            f.action = "/admin/board_list_delete";
        }

        f.token.value = generate_token();
        f.action += "?{{ request.query_params|safe }}";

        return true;
    }

    $(function() {
        $(".board_copy").click(function() {
            window.open(this.href, "win_board_copy", "left=100,top=100,width=550,height=450");
            return false;
        });
    });
    </script>
{% endblock content %}
